<%@page contentType="text/html; charset=UTF-8"%>
<%@page import="java.net.*" %>
<%@include file="../../../tools/commonTag.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>批量添加员工角色</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<link rel="stylesheet" href="${path}/style/backui/system.css">
		<script src="${path}/js/jquery-1.6.js"></script>
		<script src="${path}/js/backjs/sysutil.js"></script>
		<script src="${path}/js/backjs/tree_func.js"></script>
		<script type="text/javascript">getPath("<%=request.getContextPath()%>") ;</script>
		<script type="text/javascript">
			//员工ID，提交到后台
			var empno = "" ;
			var emprealname = "" ;
			$(function() {
				var emps = $("#emps");
				
				var emp = $("#depts ul li ol li input:[type=checkbox]") ;
				emp.click(function() {
					var e = $(this); 
					if(e.is(":checked")){
						var esplit = e.val().split(",");
						empno += esplit[0] + "," ;
						emprealname += esplit[1] + "," ;
						
						emps.val(emprealname.substring(0,emprealname.length-1));
					} else {
						var esplit = e.val().split(",");
						
						eno = esplit[0] + "," ;
						ena = esplit[1] + "," ;
	
						empno = empno.replace(eno,"") ;
						emprealname = emprealname.replace(ena,"") ;
	
						emps.val(emprealname);
					}
				});
			});

			function sendGOTO() {

				var role_id = "" ;
				
				var role = $("input:[name=role_id]:checked") ;
				
				role.each(function(){
					role_id += $(this).val() + "," ;
				});
				alert(empno + "==" + emprealname) ;
				alert(role_id) ;

				if(undefined != empno && "" != empno && role_id) {
					window.location.href="emp!assignPrivilegeMoreEmp.action?empids="+empno.substring(0,empno.length-1)+"&roleids="+role_id.substring(0,role_id.length-1);
				} else {
					alert("员工或者角色未选中！") ;
				}
				
			} 
		</script>
		<style type="text/css">
			ul {
			    margin:0px;
			    padding:0px;
			}
			.clsul li {
			    background: url("${path}/images/backui/dot.png") no-repeat scroll 3px center transparent;
			    line-height: 20px;
			    list-style-type: none;
			    margin: 0 0 0 10;
			    padding: 0 0 0 16px;
			}
		</style>
	</head>

	<body>
		<div id="main">
			<div id="page_body">
				<div class="page_title">
					
				</div>
				<div class="page_content">
					<div style="border:1px solid #4686C6;width:63%;height:385px; float:left;margin-left:50px;">
						<div style="border-right:1px solid #4686C6;border-bottom:1px solid #4686C6;width:100px;height:88px;padding-top:35px;float:left;">
							员工：
						</div>
						<div style="border-bottom:1px solid #4686C6;width:532px;height:88px;float:left;">
							<textarea rows="5" cols="60" style="width:530px;" id="emps"></textarea>
						</div>
						<div style="border-right:1px solid #4686C6;border-bottom:1px solid #4686C6;width:100px;height:250px;padding-top:35px;float:left;">
							角色：
						</div>
						<div style="border-bottom:1px solid #4686C6;width:532px;height:250px;float:left;">
							<c:forEach var="roles" items="${role}" varStatus="v">
								<div style="text-align:left;width:130px;height:25px;float:left;">
									<input type="checkbox" name="role_id" value="${roles.r_id}"/>
									${roles.r_id}--${roles.r_name}
								</div>
							</c:forEach>
						</div>
						<div style="background:#E7F0FB;padding-top:5px;border-top:1px solid #4686C6;border-bottom:1px solid #4686C6;width:633px;height:35px;margin-top:5px;float:left;">
							<input type="button" onclick="sendGOTO();" class="BigButtonA" value="分配">
						</div>
					</div>
					<div id="depts" style="border:1px solid #4686C6;width:22%;height:385px;text-align:left; float:left;margin-left:50px;overflow-y: scroll;">
						<c:forEach var="depts" items="${dept}">
							<ul>
								<li>${depts.deptName }
									<c:forEach var="emps" items="${depts.emp}">
										<ol>
											<li>${emps.empNo}-${emps.empRealname}<input type="checkbox" name="emp" value="${emps.empNo},${emps.empRealname}"/></li>
										</ol>
									</c:forEach>
								</li>
							</ul>
						</c:forEach>
					</div>
				</div>
			</div>
		</div>
		
		<script type="text/javascript">
			var tb = $(".TableList") ;
			var title_tb = $(".small") ;
			title_tb.css("width",tb.attr("width")) ;
		</script>
	</body>
</html>
